<template>
  <div id="app" v-bind:style="appDivStyle">
      <div class="context" ref="context">
          <!-- 条件查询区 -->
        <div class="queryBox" ref="queryBox">
                <el-form :model="formQueryCondition"
                         ref="form" size="mini">
                  <el-row>
                    <el-col :span="5">
                    <el-form-item :label="$t('playBillManage.queryLabel.programCode')"   :label-width="queryformLabelWidth">
                        <el-input v-model.trim="formQueryCondition.playbillCode.val" class="queryItemStyle" clearable
                                  :placeholder="$t('playBillManage.queryLabel.placeholderProgramCode')">
                        </el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">
                    <el-form-item :label="$t('playBillManage.queryLabel.programName')"   :label-width="queryformLabelWidth">
                        <el-input v-model.trim="formQueryCondition.playbillName.val" class="queryItemStyle" clearable
                                  :placeholder="$t('playBillManage.queryLabel.placeholderProgramName')">
                        </el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">
                    <el-form-item :label="$t('playBillManage.queryLabel.channel')"    :label-width="queryformLabelWidth">
                        <el-select v-model="formQueryCondition.channelId.val" filterable >
                          <el-option :label="$t('playManage.label.all')" value=""></el-option>
                          <el-option :value="drug.keyId" :key="drug.keyId" :label="drug.channelName" v-for="drug in channelNameGroup"></el-option>
                          </el-select>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">
                    <el-form-item :label="$t('Dictionary.queryLabel.status')"  :label-width="queryformLabelWidth">
                        <el-select v-model="formQueryCondition.isEnable.val" class="queryItemStyle">
                            <el-option :label="$t('label.all')" value=""></el-option>
                            <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText"
                                v-for="drug in enables"></el-option>
                        </el-select>
                    </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="5">
                    <el-form-item :label="$t('playBillManage.queryLabel.startTime')"   :label-width="queryformLabelWidth">
                        <el-date-picker v-model.trim="formQueryCondition.playbillStart.val" class="queryItemStyle" clearable
                                :placeholder="$t('queryLabel.selectOp')" type="datetime" :picker-options="pickerOptionsStart"
                                format="yyyy-MM-dd" value-format="yyyy-MM-dd">
                                <!-- :picker-options="pickerOptionsStart" -->
                        </el-date-picker>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">
                    <el-form-item :label="$t('playBillManage.queryLabel.timeTo')"   :label-width="queryformLabelWidth">
                        <el-date-picker v-model.trim="formQueryCondition.playbillEnd.val" class="queryItemStyle" clearable
                                :placeholder="$t('queryLabel.selectOp')" type="datetime" :picker-options="pickerOptionsEnd"
                                format="yyyy-MM-dd" value-format="yyyy-MM-dd">
                                <!-- :picker-options="pickerOptionsEnd" -->
                        </el-date-picker>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">
                    <el-form-item :label="$t('playBillManage.queryLabel.sendtoState')"  :label-width="queryformLabelWidth">
                        <el-select v-model="formQueryCondition.sendtoState.val" class="queryItemStyle">
                            <el-option :label="$t('label.all')" value=""></el-option>
                            <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText"
                                v-for="drug in sendStateGroup"></el-option>
                        </el-select>
                    </el-form-item>
                    </el-col>
                  </el-row>

                <el-row>
                  <el-col :span="24">
                    <div style="text-align:right">
                        <!-- <el-form-item >
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'grabProgramBtnText'}" type="primary" @click="onPlay('grabProgramBtnText')" icon="el-icon-refresh">{{$t('playBillManage.btnText.freshBtnText')}}</el-button>
                        </el-form-item> -->
                        <el-form-item>
                          <!-- 新增 -->
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'saveBtnText'}" type="primary" @click="onAdd('saveBtnText')" >{{$t('playBillManage.btnText.addBtnText')}}</el-button>
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'grabProgramBtnText'}" type="primary" @click="onCatch('grabProgramBtnText')" >{{$t('playBillManage.btnText.catchBillBtnText')}}</el-button>
                        <!--批量下发-->
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'batchSendBtnText'}" type="primary" @click="onBatchSend('batchSendBtnText')">{{$t('playBillManage.btnText.sendBatchBtnText')}}</el-button>
                        <!-- 下发记录 -->
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'sendRecordBtnText'}" type="primary" @click="sendRecord('sendRecordBtnText')">{{ $t('playBillManage.btnText.queryRecycleBin') }}</el-button>
                        <!--导入-->
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'ImportBtnText'}" type="primary" @click="openUploadDlg('ImportBtnText')" icon="el-icon-upload2" :loading="loading">{{ $t('playBillManage.btnText.importBtnText') }}</el-button>
                        <!--导入模板下载-->
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'downloadTemplate'}" type="primary" @click="downloadTemplate('downloadTemplate')" icon="el-icon-download" :loading="loading">{{ $t('playManage.btnText.downloadTemplate') }}</el-button>
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'resetBtnText'}" type="primary" @click="onReset('form')">{{ $t('btnText.resetBtnText') }}</el-button>
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'queryBtnText'}" type="primary" @click="onQuery('queryBtnText')" icon="el-icon-search" :loading="loading">{{ $t('btnText.queryBtnText') }}</el-button>
                        </el-form-item>
                    </div>
                  </el-col>
                </el-row>
                </el-form>
            </div>

            <!-- 数据展示区 -->
            <div class="dataBox" ref="dataBox">

                <el-table v-if="isInit" ref="singleTable"
                            :data="tableData"
                            :height="tableHeight"
                            @sort-change="sortChange"
                            @selection-change="changeBox"
                            v-loading="loading" size="mini"
                            style="width: 100%;" stripe=stripe border=border>

                    <el-table-column type="selection" width="55" fixed="left" align="center" :selectable="selectable">
                    </el-table-column>

                    <el-table-column width="250" fixed="left"
                        :label="$t('table.op')" align="center">
                        <template slot-scope="scope">
                            <el-button size="gv" icon="el-icon-edit"
                                v-permission="{menuCode: menuCode, resourceCode: 'editBtnText'}"
                                :loading="loading" @click="edit(scope.$index, scope.row,'editBtnText')"
                                    >{{ $t('playBillManage.btnText.editBtnText') }}</el-button>
                            <!--下发-->
                            <el-button size="gv" icon="el-icon-delete"
                                v-permission="{menuCode: menuCode, resourceCode: 'sendBtnText'}"
                                    type="danger" :loading="loading" @click="onSend(scope.$index, scope.row,'sendBtnText')"
                                    :disabled="scope.row.sendtoState==='DownAlready'">{{ $t('ParentAssetIssuance.btnText.sendBtnText') }}</el-button>
                           <!-- <el-button size="gv" icon="el-icon-delete" type="danger"
                                :loading="loading" @click="logoffRow(scope.$index, scope.row)"
                                            >{{ $t('btnText.logoffBtnText') }}</el-button> -->
                             <el-button size="gv" icon="el-icon-delete" v-show="scope.row.isEnable=='Invalid'"
                                     type="danger" :loading="loading" @click="deleteRow(scope.$index, scope.row,'deleteBtnText')"
                                     v-permission="{menuCode: menuCode, resourceCode: 'deleteBtnText'}"
                                    >{{ $t('btnText.deleteBtnText') }}</el-button>
                             <el-button size="gv" icon="el-icon-delete" v-show="scope.row.isEnable=='Available'"
                                    type="danger" :loading="loading" @click="logoffRow(scope.$index, scope.row,'passBtnText')"
                                    v-permission="{menuCode: menuCode, resourceCode: 'passBtnText'}"
                                    >{{ $t('btnText.logoffBtnText') }}</el-button>
                              <!-- 恢复 -->
                                <el-button size="gv" icon="el-icon-delete" v-show="scope.row.isEnable=='Invalid'"
                                v-permission="{menuCode: menuCode,resourceCode: 'recoveryBtnText'}"
                                      type="danger" :loading="loading" @click="revertLogoffRow(scope.$index, scope.row,'recoveryBtnText')"
                                     >{{ $t('btnText.recoveryBtnText') }}</el-button>
                        </template>
                    </el-table-column>
                    <el-table-column prop="playbillCode" min-width="110" fixed="left"
                        :label="$t('playBillManage.table.programCode')" sortable="custom" sort-by="playbillCode">
                    </el-table-column>
                    <el-table-column prop="playbillName" min-width="180" fixed="left"
                        :label="$t('playBillManage.table.programName')" sortable="custom" sort-by="playbillName">
                    </el-table-column>
                    <el-table-column prop="channelName" min-width="180"
                        :label="$t('playBillManage.table.channel')" sortable="custom" sort-by="channelName">
                    </el-table-column>
                    <el-table-column prop="sendtoStateName" min-width="120"
                        :label="$t('playBillManage.table.sendtoState')" sortable="custom" sort-by="sendtoState">
                    </el-table-column>
                    <el-table-column prop="playbillStart" min-width="180"
                        :label="$t('playBillManage.table.startTime')" sortable="custom" sort-by="playbillStart">
                    </el-table-column>
                    <el-table-column prop="playbillEnd" min-width="180"
                        :label="$t('playBillManage.table.endTime')" sortable="custom" sort-by="playbillEnd">
                    </el-table-column>
                    <el-table-column prop="duration" min-width="120"
                        :label="$t('playBillManage.table.programPeriod')" sortable="custom" sort-by="duration">
                    </el-table-column>
                    <el-table-column prop="lastUpdatedDate" min-width="180"
                        :label="$t('playBillManage.table.lastUpdateTime')" sortable="custom" sort-by="lastUpdatedDate">
                    </el-table-column>
                    <el-table-column prop="modifier" min-width="140"
                        :label="$t('playBillManage.table.lastUpdateBy')" sortable="custom" sort-by="modifier">
                    </el-table-column>
                    <!-- <el-table-column prop="sendtoState" min-width="140"
                        :label="$t('playManage.tableText.status')" sortable="custom" sort-by="sendtoState">
                    </el-table-column> -->
                    <el-table-column prop="isEnableName" min-width="140"
                        :label="$t('playManage.tableText.status')" sortable="custom" sort-by="isEnable">
                    </el-table-column>
                </el-table>


            </div>
        </div>

        <!-- 翻页选择区 -->
        <div class="pageBox">
            <el-pagination @size-change="sizeChange"
                            @current-change="currentPageChange"
                            :current-page="pager.curPage"
                            :page-sizes="pager.sizes"
                            :page-size="pager.curSize"
                            :background="true"
                            layout="total, sizes, prev, pager, next, jumper" :total="pager.total">
            </el-pagination>
        </div>

         <!--编辑对话框-->
        <el-dialog :title="$t('label.dialogTitle')" :visible.sync="isShowEditForm" top="5vh" :close-on-click-modal="false">
            <el-form :model="editForm" ref="editForm" size="mini"
                     :label-position="editFormPosition" status-icon=status-icon :rules="editRules">

                <!--节目编号-->
                <el-form-item :label="$t('playBillManage.queryLabel.programCode')" :label-width="editformLabelWidth" prop="playbillCode">
                    <el-input v-model.trim="editForm.playbillCode" :disabled="isEnabled"
                              :placeholder="$t('playBillManage.queryLabel.placeholderProgramCode')"></el-input>
                </el-form-item>
                <!-- 节目名称 -->
                <el-form-item :label="$t('playBillManage.queryLabel.programName')" :label-width="editformLabelWidth" prop="playbillName">
                    <el-input v-model.trim="editForm.playbillName"
                              :placeholder="$t('playBillManage.queryLabel.placeholderProgramName')"></el-input>
                </el-form-item>
                <!-- 所属频道 -->
                <el-form-item :label="$t('playBillManage.queryLabel.channel')" :label-width="editformLabelWidth" prop="channelId">
                   <el-select v-model="editForm.channelId">
                          <el-option :value="drug.keyId" :key="drug.keyId" :label="drug.channelName" v-for="drug in channelNameGroup"></el-option>

                   </el-select>
                </el-form-item>
                <!--开始时间-->
                <el-form-item :label="$t('playBillManage.queryLabel.startTime')" :label-width="editformLabelWidth" prop="playbillStart">
                    <el-date-picker @change="duration" v-model="editForm.playbillStart" type="datetime"  formatDate="yyyy-MM-dd HH:mm:ss" :placeholder="$t('playBillManage.editLabel.placeholderStartTime')"></el-date-picker>
                    <!-- <el-time-picker v-model="editForm.playbillStart" :picker-options="{ selectableRange: '00:00:00 - 23:59:59'}" :placeholder="$t('playBillManage.editLabel.placeholderStartTime')"></el-time-picker> -->
                </el-form-item>
                <!--结束时间-->
                <el-form-item :label="$t('playBillManage.queryLabel.endTime')" :label-width="editformLabelWidth" prop="playbillEnd">
                    <el-date-picker @change="duration" v-model="editForm.playbillEnd" type="datetime"  format="yyyy-MM-dd HH:mm:ss"  :placeholder="$t('playBillManage.editLabel.placeholderEndTime')"></el-date-picker>
                    <!-- <el-time-picker v-model="editForm.playbillEnd" :picker-options="{ selectableRange: '00:00:00 - 23:59:59'}" :placeholder="$t('playBillManage.editLabel.placeholderEndTime')"></el-time-picker> -->
                </el-form-item>
                <!-- 计算时长 -->
                <el-form-item :label="$t('playBillManage.editLabel.billDuration')" :label-width="editformLabelWidth" prop="duration">
                    <el-input v-model.trim="editForm.duration"  :disabled="true"></el-input>
                </el-form-item>
                <!-- 节目介绍 -->
                <el-form-item :label="$t('playBillManage.editLabel.programDesc')" :label-width="editformLabelWidth" prop="playbillDesc">
                    <el-input v-model.trim="editForm.playbillDesc"   type="textarea" :placeholder="$t('playBillManage.editLabel.placeholderProgramDesc')"></el-input>
                </el-form-item>
                <!-- 节目海报 -->
                <el-form-item :label="$t('playBillManage.editLabel.programPoster')" :label-width="editformLabelWidth" prop="posters">
                    <el-input v-model="editForm.posters"  width="120" v-show="false"></el-input>
                    <el-upload
                        class="avatar-uploader"
                        :action="action"
                        :data="{site:'public',type:'playbill_poster'}"
                        :show-file-list="false"
                        :on-success="handleAvatarSuccess"
                        :before-upload="beforeAvatarUpload">
                        <img v-if="imageUrl" :src="imageUrl" class="avatar">
                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                      </el-upload>
                </el-form-item>

            </el-form>
            <div slot="footer">
                <!--取消按钮-->
                <el-button size="mini" @click="isShowEditForm = false" :loading="loading">{{ $t('btnText.cancelBtnText') }}</el-button>
                <!--保存按钮-->
                <el-button size="mini" type="primary" @click="submitForm('editForm',currentResCode)" :loading="loading">{{ $t('btnText.saveBtnText') }}</el-button>
            </div>
        </el-dialog>

      <!-- 下发对话框 -->
        <transition enter-active-class="animated rotateIn" leave-active-class="animated rotateOut">
        <el-dialog :title="$t('playBillManage.label.releaseDialogTitle')" :visible.sync="isShowEditForm2" top="5vh" @close="refresh" :close-on-click-modal="false">
            <el-form :inline="true" :model="sendForm" ref="sendForm" size="mini"
                     :label-position="editFormPosition" status-icon=status-icon :rules="sendRules">
            <el-row>
                <el-form-item :label="$t('')" :label-width="editformLabelWidth" prop="siteList">
                    <el-checkbox-group v-model="sendForm.siteList" >
                        <el-checkbox :value="item.siteName" :key="item.keyId" :label="item.keyId" v-for="item in channelData">{{item.siteName}}</el-checkbox>
                    </el-checkbox-group>
                </el-form-item>
            </el-row>
            </el-form>
            <div slot="footer">
                <el-button size="mini" @click="isShowEditForm2 = false" :loading="loading">{{ $t('btnText.cancelBtnText') }}</el-button>
                <el-button size="mini" type="primary" @click="comfirmSend('sendForm',currentResCode)" :loading="loading">{{ $t('btnText.sendConfirmBtnText') }}</el-button>
            </div>
        </el-dialog>
      </transition>

        <!--下发记录页面-->
      <el-dialog :title="$t('playManage.label.sendRecord')" :visible.sync="isShowInfoForm4" top="5vh" width="960px" :close-on-click-modal="false">
         <div class="queryBox" ref="queryBox">
                <el-form :model="formQueryCondition2"
                         ref="form" size="mini">
                  <el-row>
                    <el-col :span="7">
                    <el-form-item :label="$t('playBillManage.queryLabel.programCode')"   :label-width="queryformLabelWidth">
                        <el-input v-model.trim="formQueryCondition2.playBillCode.val" class="queryItemStyle" clearable
                                  :placeholder="$t('playBillManage.queryLabel.placeholderProgramCode')">
                        </el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="7" :offset="1">
                    <el-form-item :label="$t('playBillManage.queryLabel.programName')"   :label-width="queryformLabelWidth">
                        <el-input v-model.trim="formQueryCondition2.playBillName.val" class="queryItemStyle" clearable
                                  :placeholder="$t('playBillManage.queryLabel.placeholderProgramName')">
                        </el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="7" :offset="1">
                    <el-form-item :label="$t('playBillManage.queryLabel.sendtoState')" disabled :label-width="queryformLabelWidth">
                        <el-select v-model="formQueryCondition2.sendtoState.val" class="queryItemStyle">
                            <el-option :label="$t('label.all')" value=""></el-option>
                            <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText"
                                v-for="drug in sendStateGroup"></el-option>
                        </el-select>
                    </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="7">
                    <el-form-item :label="$t('playBillManage.queryLabel.startTime')"   :label-width="queryformLabelWidth">
                        <el-date-picker v-model.trim="formQueryCondition2.createDateStart.val" class="queryItemStyle" clearable
                                :placeholder="$t('queryLabel.selectOp')" type="datetime" :picker-options="pickerOptionsStart"
                                format="yyyy-MM-dd" value-format="yyyy-MM-dd">
                                <!-- :picker-options="pickerOptionsStart" -->
                        </el-date-picker>
                    </el-form-item>
                    </el-col>
                    <el-col :span="7" :offset="1">
                    <el-form-item :label="$t('playBillManage.queryLabel.timeTo')"   :label-width="queryformLabelWidth">
                        <el-date-picker v-model.trim="formQueryCondition2.createDateEnd.val" class="queryItemStyle" clearable
                                :placeholder="$t('queryLabel.selectOp')" type="datetime" :picker-options="pickerOptionsEnd"
                                format="yyyy-MM-dd" value-format="yyyy-MM-dd">
                                <!-- :picker-options="pickerOptionsEnd" -->
                        </el-date-picker>
                    </el-form-item>
                    </el-col>
                    <el-col :span="7" :offset="1">
                    <el-form-item :label="$t('assetsDR.queryLabel.status')"   :label-width="queryformLabelWidth">
                        <el-select v-model="formQueryCondition2.state.val" class="queryItemStyle">
                            <el-option :label="$t('assetsDR.label.all')" value=""></el-option>
                            <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText" v-for="drug in States"></el-option>
                        </el-select>
                    </el-form-item>
                    </el-col>
                  </el-row>
                  <!-- <el-row>
                    <el-col :span="7">
                      <el-form-item :label="$t('Dictionary.queryLabel.status')"  :label-width="queryformLabelWidth">
                          <el-select v-model="formQueryCondition2.isEnable.val" class="queryItemStyle">
                              <el-option :label="$t('label.all')" value=""></el-option>
                              <el-option :value="drug.valueCode" :key="drug.valueCode" :label="drug.valueText"
                                  v-for="drug in enables"></el-option>
                          </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row> -->

                <el-row>
                  <el-col :span="24">
                    <div style="text-align:right">
                        <el-form-item>
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'resetBtnText'}" type="primary" @click="onReset2('form')">{{ $t('btnText.resetBtnText') }}</el-button>
                            <el-button v-permission="{menuCode:menuCode,resourceCode:'queryBtnText'}" type="primary" @click="onQuery2('queryBtnText')" icon="el-icon-search" :loading="loading">{{ $t('btnText.queryBtnText') }}</el-button>
                        </el-form-item>
                    </div>
                  </el-col>
                </el-row>
                </el-form>
            </div>
            <el-table v-if="isInit" ref="singleTable"
                                :data="tableData2"
                                :height="tableHeight"
                                @sort-change="sortChange2"
                                v-loading="loading" size="mini"
                                style="width: 100%;" stripe=stripe border=border>
                        <el-table-column prop="playBillCode" min-width="140" fixed="left"
                                            :label="$t('assetsDR.tableText.assetsCode')" sortable="custom" sort-by="playBillCode">
                        </el-table-column>
                        <el-table-column prop="playBillName" min-width="190" fixed="left"
                                            :label="$t('assetsDR.tableText.assetsName')" sortable="custom" sort-by="playBillName">
                        </el-table-column>
                        <el-table-column prop="siteName" min-width="150"
                        :label="$t('assetsDR.tableText.siteName')" sortable="custom" sort-by="siteName">
                        </el-table-column>
                        <!-- <el-table-column prop="vChannelLendLogEntity.type" min-width="150"
                        :label="$t('assetsDR.tableText.type')" sortable="custom" sort-by="type">
                        </el-table-column> -->
                        <el-table-column :label="$t('assetsDR.tableText.status')" min-width="120" sortable="custom" prop="state" sort-by="state">
                        </el-table-column>
                        <el-table-column :label="$t('playBillManage.table.sendtoState')" min-width="120" sortable="custom" prop="sendToState" sort-by="sendToState">
                        </el-table-column>
                        <el-table-column :label="$t('assetsDR.tableText.message')" min-width="220" sortable="custom" prop="message" sort-by="message">
                        </el-table-column>
                        <el-table-column :label="$t('assetsDR.tableText.createTime')" min-width="180" sortable="custom" prop="createDate" sort-by="createDate">
                        </el-table-column>

            </el-table>
               <!-- 翻页选择区 -->
        <div class="pageBox">
            <el-pagination @size-change="sizeChange2"
                            @current-change="currentPageChange2"
                            :current-page="pager2.curPage"
                            :page-sizes="pager2.sizes"
                            :page-size="pager2.curSize"
                            :background="true"
                            layout="total, sizes, prev, pager, next, jumper" :total="pager2.total">
            </el-pagination>
        </div>
        </el-dialog>
      <el-dialog :title="this.$i18n.t('label.import')" width="400px" :visible.sync="dlgUploadVisible" :close-on-click-modal="false">
       <upload-file
        v-bind:uploadUrl="uploadCourseMaterialUrl"
        v-bind:acceptFileType="'.xlsx'"
        v-bind:uploadParams="uploadCourseMaterialParams"
        v-bind:fileList="fileList"
        v-bind:autoUpload="false"
        v-bind:fileLimit="1"
        v-bind:selectName="this.$i18n.t('label.selectName')"
        v-bind:uploadBtn="this.$i18n.t('label.submit')"
        v-bind:fileTypeText="'xlsx'"
        v-bind:submitSuccess="submitUploadSuccess"
        v-bind:menuCode="menuCode"
      ></upload-file>
    </el-dialog>

  </div>


</template>

<script>

import comBaseVue from '../../baseViewModel';
import ProgramList from './ProgramList';

export default {
  mixins: [comBaseVue],
  name:'PlayBillManage',
  props: {
    menuCode: String
  },

  data () {

    return {
        isEnabled: false,
        isShowEditForm2:false,
        isShowInfoForm: false,
        isSendEditForm:false,
        isShowInfoForm4:false,
        isShowRecycle: false,
        activeName: 'first',
        lookName: 'look',
        isInit:false,
        siteData:[],
        channelData:[],
        tableHeight:100,
        channelNameGroup:[],
        multipleSelection: [],
        tableData2: [],
        enables: [],
        States:[],
        sendStateGroup:[],
        show:false,
        appDivStyle:{
            height:this.$store.getters.appHeight,
        },
        // 分页对象
            pager2: {
                curPage: 1,
                sizes: [20, 30, 50, 100, 200, 400],
                curSize: 20,
                total: 0
            },
        appDivStyle:{
            height:this.$store.getters.appHeight,
        },
        // 排序对象
            sort2: {
                key: "keyId",
                dir: "Desc"
            },
        modelName:"com.ispr.iptv.entity.live.PlaybillEntity",

        modelName2:"com.ispr.iptv.entity.live.VPlayBillChannelLendLogEntity",
        // 查询条件
        formQueryCondition: {
            playbillCode: {
                key: 'playbillCode',
                op: 'LIKE',
                val: ''
            },
            playbillName: {
                key: 'playbillName',
                op: 'LIKE',
                val: ''
            },
            parentSite: {
                key:'parentSite',
                val: '',
                op: '='
            },
              channelId:{
                key: 'channelId',
                val:'',
                op: '=',
                },
            playbillStart: {
                key: 'playbillStart',
                val: '',
                op:'>='
            },
            playbillEnd: {
                key: 'playbillEnd',
                val: '',
                op:'<='
            },
            isEnable:{
              key:'isEnable',
              op: '=',
              val:''
            },
            sendtoState:{
              key:'sendtoState',
              op: '=',
              val:''
            },
        },
        // 下发记录查询条件
        formQueryCondition2: {
            playBillCode: {
                key: 'playBillCode',
                op: 'LIKE',
                val: ''
            },
            playBillName: {
                key: 'playBillName',
                op: 'LIKE',
                val: ''
            },
            // siteName: {
            //     key:'siteName',
            //     val: '',
            //     op: '='
            // },
            createDateStart: {
                key: 'createDate',
                val: '',
                op:'>=',
                group:'1'//时间区间查询，两个group的值不一样进行与运算否则进行或运算
            },
            createDateEnd: {
                key: 'createDate',
                val: '',
                op:'<=',
                group:'2'
            },
            sendtoState:{
              key: 'sendToState',
              op: '=',
              val: 'DownAlready'
            },
            state:{
              key: 'state',
              op: '=',
              val: ''
            },
        },

         // 编辑面板(审核)绑定的对象
        editForm: {
            keyId: 0,
            version: 0,
            playbillCode: "",
            playbillName: "",
            channelId: "",
            playbillStart: "",
            playbillEnd: "",
            duration: "",
            playbillDesc: "",
            posters: "",
            isEnable:"Available",
            sendtoState:"StayDown"
        },
        // 编辑面板(审核)的验证规则
        editRules: {
            playbillCode: [{ required: true, message: this.$i18n.t('playBillManage.rules.placeholderProgramCode'), trigger: 'blur' }],
            playbillName: [{ required: true, message: this.$i18n.t('playBillManage.rules.placeholderProgramName'), trigger: 'blur' }],
            channelId: [{ required: true, message: this.$i18n.t('playBillManage.rules.placeholderChannel'), trigger: 'blur' }],
            playbillStart: [{ required: true, message: this.$i18n.t('playBillManage.rules.placeholderStartTime'), trigger: 'blur' }],
            playbillEnd: [{ required: true, message: this.$i18n.t('playBillManage.rules.placeholderEndTime'), trigger: 'blur' }]
        },

        pickerOptionsStart:{
          disabledDate: time => {
          let endDateVal = this.formQueryCondition.playbillEnd.val;
          if (endDateVal) {
            // alert(time.getTime());
            return time.getTime() > new Date(endDateVal).getTime();
          }
        }
      },
      pickerOptionsEnd: {
        disabledDate: time => {
          let beginDateVal = this.formQueryCondition.playbillStart.val;
          if (beginDateVal) {
            return (
              time.getTime() <
              new Date(beginDateVal).getTime() - 1 * 24 * 60 * 60 * 1000

            );
          }
        }
        },
      sendRules: {
          siteList: [{ required: true, message: this.$i18n.t('ParentAssetIssuance.rules.sendCheckTip'), trigger: 'blur' }],
      },
      //下发
      sendForm: {
          siteList: [],//下发到的站点
          sendType:"",
      },
      imageUrl: '',
      uploadCourseMaterialUrl: '/api/importPlaybill/upload',
      uploadCourseMaterialParams: null,
      dlgUploadVisible: false,
      fileList: [],
      loading2:false,
      // 排序对象
      sort: {
          key: "playbillStart",
          dir: "asc"
      },
    }
  },
  methods:{
      selectable(row,index){
        if((row.sendtoState !=="DownAlready")){
          return true;
        }else{
          return false;
        }
      },

     // 分页容量变化
        sizeChange2: function(val) {
            this.pager2.curPage = 1;
            this.pager2.curSize = val;
            this.queryTable2();
        },
         // 分页按钮
        currentPageChange2: function (val) {
            this.pager2.curPage = val;
            this.queryTable2();
        },
          // 排序回调函数
        sortChange2: function(sortObj) {
            // alert(JSON.stringify(sortObj));
            // console.log(sortObj);
            this.pager2.curPage = 1;
            this.sort2.key = sortObj.column.sortBy;
            if (sortObj.order == "ascending") {
                this.sort2.dir = "asc";
            } else {
                this.sort2.dir = "desc";
            }
            this.queryTable2();
        },
        onCatch: function(){

        },
        onAdd: function(rescode) {
          this.currentResCode = (rescode && rescode!=='') ? rescode : '';
            // this.isEnabled = false;
            this.isShowEditForm = true;
            if (this.$refs['editForm']) {
                this.$refs['editForm'].resetFields();
            }
            this.editForm.keyId = "";
            this.editForm.version = "";
            this.editForm.playbillCode = "",
            this.editForm.playbillName= "",
            this.editForm.channelId = "",
            this.editForm.playbillStart = "",
            this.editForm.playbillEnd = "",
            this.editForm.duration ="",
            this.editForm.posters = "",
            this.editForm.playbillDesc = "",
            this.editForm.sendtoState = "StayDown",
            this.imageUrl = '';
            this.fileList = [];
            this.curCommand = "SaveNewReturnPK";
            this.canEditCode = false;
        },

        // 查询网格数据
        queryTable: function() {
            this.loading = true;
            this.queryModel("com.ispr.iptv.entity.live.VPlaybillEntity","Query",this.formQueryCondition,this.pager,this.sort,this.setTableData)
        },

    // 下发记录
      sendRecord:function(rescode){
          this.currentResCode = (rescode && rescode!=='') ? rescode : '';
          this.isShowInfoForm4 = true;
          this.onReset2();
          this.onQuery2();
        },
      // 查询按钮
        onQuery2: function() {
            this.pager2.curPage = 1;
            this.queryTable2();
        },
         // 查询网格数据
        queryTable2: function() {
            this.loading = true;

            this.queryModel(this.modelName2,"Query",this.formQueryCondition2,this.pager2,this.sort2,this.setTableData2)
        },
        // 查询网格数据成功后的回调
        setTableData2: function(isSuccess,json) {
            this.loading = false;
            try{
                if (isSuccess) {
                    // alert(JSON.stringify(json));
                    this.pager2.total = json.total;
                    this.tableData2 = [];
                    for (var i = 0; i < json.list.length; i++) {
                        this.tableData2.push(json.list[i]);
                    }

                }
                else {
                    this.$message.error(json.msg);
                }
            }
            catch(e){
                alert(e);
            }
        },

        // 重置
    onReset2:function(){
        if (this.$refs['form']) {
            this.$refs['form'].resetFields();
        }
        this.formQueryCondition2.playBillCode.val = "";
        this.formQueryCondition2.playBillName.val = "";
        this.formQueryCondition2.createDateStart.val = "";
        this.formQueryCondition2.createDateEnd.val = "";
        this.formQueryCondition2.sendtoState.val = "DownAlready";
        this.formQueryCondition2.state.val = "";

    },

    //编辑面板提交后调用，设置唯一性验证条件
    setEditFormCheck:function setEditFormCheck(){
        if(this.curCommand == "SaveNewReturnPK"){
            this.editFormCheck = [{
                    key: 'playbillCode',
                    op: '=', // 操作符
                    val: this.editForm.playbillCode// 查询的值
                },
                // {
                //     key: 'isEnable',
                //     op: '=', // 操作符
                //     val: 'Available'
                // },
                {
                  key:'playbillName',
                  op:'=',
                  val: this.editForm.playbillName
                }];
        }else if(this.curCommand == "PartialUpdateProc"){
            this.editFormCheck = [{
                    key: 'playbillCode',
                    op: '=', // 操作符
                    val: this.editForm.playbillCode// 查询的值
                },
                // {
                //     key: 'isEnable',
                //     op: '=', // 操作符
                //     val: 'Available'
                // },
                {
                    key: 'keyId',
                    op: '<>', // 操作符
                    val: this.editForm.keyId
                },{
                  key:'playbillName',
                  op:'=',
                  val: this.editForm.playbillName
                }];
        }

    },

    // 编辑按钮回调事件
    editCallback: function(isSuccess, json) {
      if (isSuccess) {
        this.curCommand = "PartialUpdateProc";
        this.isShowEditForm = true;
        if (this.$refs["editForm"]) {
          this.$refs["editForm"].resetFields();
        }
        this.editForm.keyId = json.keyId;
        this.editForm.version = json.version;
        this.editForm.playbillName = json.playbillName;
        this.editForm.playbillCode = json.playbillCode;
        this.editForm.channelId = json.channelId;
        this.editForm.playbillStart = json.playbillStart;
        this.editForm.playbillEnd = json.playbillEnd;
        this.editForm.duration = this.billDuration(json.playbillStart,json.playbillEnd);
        this.editForm.playbillDesc = "";
        if(json.playbillDesc!=null){
        this.editForm.playbillDesc = json.playbillDesc;}
        this.editForm.posters = "";
        if(json.posters != null){
        this.editForm.posters = json.posters;}
        this.editForm.sendtoState = "StayDown";
        this.imageUrl = json.posters;
        // this.canEditCode = true;
      } else {
        this.$message({
          message: json.msg,
          type: "warning"
        });
      }
    },

     // 重置
    onReset:function(){
        if (this.$refs['form']) {
            this.$refs['form'].resetFields();
        }
        this.formQueryCondition.playbillCode.val = "";
        this.formQueryCondition.playbillName.val = "";
        this.formQueryCondition.channelId.val = "";
        this.formQueryCondition.playbillStart.val = "";
        this.formQueryCondition.playbillEnd.val = "";
        this.formQueryCondition.sendtoState.val = "";
        this.formQueryCondition.isEnable.val = "";

    },
    handleAvatarSuccess(res, file) {
        //alert(res.data);
        //alert(URL.createObjectURL(file.raw));
        this.imageUrl = res.data;
        this.editForm.posters = res.data;
      },
      beforeAvatarUpload(file) {
        const isJPG = file.type === 'image/jpeg';
        const isLt2M = file.size / 1024 / 1024 < 1;

        if (!isJPG) {
          this.$message.error('上传图片只能是 JPG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传图片大小不能超过 1MB!');
        }
        return isJPG && isLt2M;
      },
    refresh: function(){
        if (this.$refs['sendForm']) {
            this.$refs['sendForm'].resetFields();
        }
        this.sendForm.siteList = [];
    },
    //单个下发
    onSend: function(index, row,rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        this.sendForm.sendType = "single";
        this.singleSend = {};
        let keyId = row.keyId;
        let version = row.version;
        let sendtoState = "DownAlready";
        let data = {"keyId":keyId,"version":version,"sendtoState":sendtoState};
        this.singleSend = data;
        let channelId = row.channelId;
        this.channelData = [];
        this.findChannelSite(channelId);
        //this.findSite();
        this.isShowEditForm2 = true;
    },

    // 批量下发
    onBatchSend: function(rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
      if(this.multipleSelection.length==0){

          this.$message({
              message: this.$i18n.t("AssetIssuance.label.checkTip"),
              type: 'warning'
          });
          return;
      }
      else{
        let chId="";
        for(var i=0;i<this.multipleSelection.length;i++){
          if(chId!="" && chId!=this.multipleSelection[i].channelId){
            this.$message({
                message: this.$i18n.t("playBillManage.message.error"),
                type: 'warning'
            });
            return;
          }else{
            chId=this.multipleSelection[i].channelId;
          }
        }
        this.channelData = [];
        this.findChannelSite(chId);
      }
      this.sendForm.sendType = "batch";
      this.isShowEditForm2 = true;
    },
    // 提交下发界面数据
    comfirmSend: function (formName,rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        var _this = this;
        let dataList = [];//最终传给后台的总数据
        let siteListJson = [];//站点的数据
        for (let i=0;i<this.sendForm.siteList.length;i++){
            let siteId = this.sendForm.siteList[i];
            let resType = "CL";
            let state = "处理成功";
            let data = {"siteId":siteId,"resType":resType,"state":state};
            siteListJson.push(data);
        };
        if(this.sendForm.sendType=="batch"){
            for(let i=0;i<this.multipleSelection.length;i++){
                let temp = this.multipleSelection[i];
                temp.siteList = siteListJson;
                dataList.push(temp);
            }
        }else if(this.sendForm.sendType=="single"){
            this.singleSend.siteList = siteListJson;
            dataList.push(this.singleSend);
        }
        this.$refs[formName].validate(function (valid) {
            if (valid) {
                _this.loading = true;
                _this.procCommand("MediaSendToProc",
                _this.modelName,
                "Default",
                {
                    "dataList":dataList,
                },
                null,
                _this.comfirmSendCallback);
            } else {
                return false;
            }
        });
    },
    // 执行命令后的回调函数
    comfirmSendCallback: function (isSuccess,json) {
        this.loading = false;
        if(isSuccess){
            this.isShowEditForm2 = false;
            this.$message({
                message: this.$i18n.t("message.successTip"),//resource.message.successTip,
                type: 'success'
            });
            this.queryTable();
        }
        else
        {
          this.$message({
            message: this.$i18n.t("errorCode." + json.reason),
            type: 'warning'
          });
        }
    },
    //根据频道ID查询下发选择的站点
    findChannelSite: function(channelId){
        var queryRequest = {
                className: "com.ispr.iptv.entity.live.ChannelEntity",//修改为被查询的实体地址
                opKey: "Query",//后台编写相应的接口实现方法，主要负责转化类型
                params: [{key: 'keyId',op: '=',val: channelId},{key: 'isEnable',op: '=',val: 'Available'}],
                userInfo: this.getUserInfo()
            };
            var _this = this;
            this.axios.post('/api/query', queryRequest, {headers: this.headersObj})
                .then(function(res) {
                    // alert(JSON.stringify(res));
                    // alert(res.data.code);

                    if (res.data.code == "SUCCESS") {
                        _this.channelData = [];
                        // _this.$nextTick(function () {sendSiteId
                            for (var i = 0; i < res.data.data.length; i++) {
                                let siteId = res.data.data[i].sendSiteId.split(',');
                                debugger
                                for(var j = 0; j<siteId.length; j++){
                                  for(var k = 0; k<_this.siteData.length; k++){
                                    if(siteId[j] == _this.siteData[k].keyId)
                                    _this.channelData.push(_this.siteData[k]);
                                  }
                                }
                                
                        }
                        // });

                    } else {
                        // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
                    }
                })
                .catch(function(error) {
                    console.log(error);
                    // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
                });
    },

     //站点复选框数据 siteData
    findSite: function(){
        var queryRequest = {
                className: "com.ispr.iptv.entity.sys.Site",//修改为被查询的实体地址
                opKey: "Query",//后台编写相应的接口实现方法，主要负责转化类型
                params: [{key: 'isEnable',op: '=',val: 'Available'}],
                userInfo: this.getUserInfo()
            };
            var _this = this;
            this.axios.post('/api/query', queryRequest, {headers: this.headersObj})
                .then(function(res) {
                    // alert(JSON.stringify(res));
                    // alert(res.data.code);

                    if (res.data.code == "SUCCESS") {
                        _this.siteData = [];
                        for (var i = 0; i < res.data.data.length; i++) {
                          _this.siteData.push(res.data.data[i]);
                            // for (var n = 0;n<_this.channelData.length; n++) {
                            //     if(_this.channelData[n] === res.data.data[i].keyId){
                            //         _this.siteData.push(res.data.data[i]);
                            //     }
                            // }
                        }
                    } else {
                        // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
                    }
                })
                .catch(function(error) {
                    console.log(error);
                    // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
                });
    },

    setSiteCallback: function(isSuccess,json){
        try{
            if (isSuccess) {
                for (var i = 0; i < json.data.length; i++) {
                    this.approvalStatusData.push(json.data[i]);
                }
            }
            else {
                this.$message.error(json.msg);
            }
        }
        catch(e){
            alert(e);
        }
    },

    changeBox: function(val) {
            this.multipleSelection = [];
            for (let i=0;i<val.length;i++){
                let keyId = val[i].keyId;
                let version = val[i].version;
                let sendtoState = "DownAlready";
                let channelId = val[i].channelId;
                let data = {"keyId":keyId,"version":version,"sendtoState":sendtoState,"channelId":channelId};
                this.multipleSelection.push(data);
            }
        },

        checkboxInit: function(row,index){
            if (row.sendtoState == '待下发') {
                return true;
            }else{
                return false;
            }
        },

    success: function(){
        this.isSendEditForm = false;
        this.$message({
                message: this.$i18n.t("message.successTip"),
                type: 'success'
        });
        this.queryTable();
    },
 /////////////////////////////////// 频道节目单信息导入 ///////////////////////////////////////////
    // 打开导入资材关系的dialog
     // 导入
    openUploadDlg: function openUploadDlg(rescode) {

      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
      let _this = this;
      // this.$alert('注意：导入后将会覆盖原有的所有数据，是否继续？', '提示', {
      //    confirmButtonText: '确定',
      //   callback: action => {
      //     if (action === 'confirm') {
            // 初始化错误文件下载id
            _this.errorTaskId = null;
            // 清空文件列表
            _this.fileList = [];
            _this.dlgUploadVisible = true;
            // this.uploadPhorderUrl = this.baseUrl+'/import/upload';
            _this.uploadCourseMaterialParams = {'className': _this.modelName};
      //     }
      //   }
      // });
    },

    submitUploadSuccess: function submitUploadSuccess (response, file, fileList,rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
      if (response.code === 'SUCCESS') {
        if (response.data.status === '0') {
          this.dlgUploadVisible = false;
          this.$message.success('导入成功');
          this.fileList = []; // 清空上传文件列表
          // 刷新表格数据
          this.onQuery();
          return false;
        }
        if (response.data.status === '3') {
          let _this = this;
          this.$alert('导入失败，是否下载失败原因文件?', '提示', {
            confirmButtonText: '确定',
            callback: function callback (action) {
              if (action === 'confirm') {
                _this.downloadByIdOrName(_this, '/import/downerr', 'taskId', response.data.taskId, response.data.errFileName);
              } else {
                _this.$message({
                  type: 'info',
                  message: '已取消'
                });
              }
            }
          });
          this.fileList = []; // 清空上传文件列表
          this.dlgUploadVisible = false;
        }
      } else {
        this.$message.error(response.msg);
      }
    },
//////////////////////////////////////////////////////////////////////////////////////////////////


    /////下载导入模板
    downloadTemplate: function downloadTemplate (rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
      this.downloadByIdOrName(this, '/import/downtemplate', 'fileName', '节目单导入模板_20190101.xlsx', '节目单导入模板_20190101.xlsx');
    },

    //
    onCatch: function(rescode){
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
      var _this = this;
      var queryRequest = {};
      if (this.isExistResourceCode(this)) {
          this.headersObj['X-AOHO-Resource'] = this.menuCode + ',' + this.currentResCode;
      }
      this.axios.post('/api/importPlaybillTxt', queryRequest, {headers: this.headersObj})
                .then(function(res) {
                    if (res.data.code == "SUCCESS") {
                        _this.$message.success(res.data.msg);
                    } else {
                        _this.$message.error(res.data.msg);
                    }
                     _this.isSiteChooseVis = false
                })
                .catch(function(error) {
                   _this.isSiteChooseVis = false
                    console.log(error);
                });
    },
    // 下线提示框
    offline() {
        this.$confirm(this.$i18n.t("playBillManage.dialog.offlineMessage"),
          this.$i18n.t("playBillManage.dialog.tip"), {
         // confirmButtonText: this.$i18n.t("playBillManage.btnText.confirmBtnText"),
          confirmButtonText: this.$i18n.t("message.yes"),
          cancelButtonText: this.$i18n.t("message.cancel"),
          type:"warning",
          callback: action => {
            this.$message({
                message: this.$i18n.t("message.successTip"),
                type: 'success'
            });
          }
        });
    },

    //所属频道下拉框
    findChannelNameGroup:function(){
      var queryRequest = {
                className: "com.ispr.iptv.entity.live.ChannelEntity",//修改为被查询的实体地址
                opKey: "Query",//后台编写相应的接口实现方法，主要负责转化类型
                params: [{key: 'isEnable',op: '=',val: 'Available'}],
                userInfo: this.getUserInfo()
            };
            var _this = this;
            this.axios.post('/api/query', queryRequest,{headers: this.headersObj})//findAllValueType修改为query
                .then(function(res) {
                    // alert(JSON.stringify(res));
                    // alert(res.data.code);
                    if (res.data.code == "SUCCESS") {
                        _this.channelNameGroup = [];
                        for (var i = 0; i < res.data.data.length; i++) {
                            _this.channelNameGroup.push(res.data.data[i]);
                        }
                    } else {
                        // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
                    }
                })
                .catch(function(error) {
                    console.log(error);
                    // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
                });
    },

    duration:function(){
      this.editForm.duration=this.billDuration(this.editForm.playbillStart,this.editForm.playbillEnd);
    },

    billDuration:function(faultDate,completeTime){
      var stime = Date.parse(new Date(faultDate));
      var etime = Date.parse(new Date(completeTime));
      var usedTime = etime - stime;  //两个时间戳相差的毫秒数
      var time = parseInt(usedTime/1000/60);
      // var days=Math.floor(usedTime/(24*3600*1000));
      // //计算出小时数
      // var leave1=usedTime%(24*3600*1000);    //计算天数后剩余的毫秒数
      // var hours=Math.floor(leave1/(3600*1000));
      // //计算相差分钟数
      // var leave2=leave1%(3600*1000);        //计算小时数后剩余的毫秒数
      // var minutes=Math.floor(leave2/(60*1000));
      // var time = days + "天"+hours+"时"+minutes+"分";
      return time;
    },
     // 为状态下拉框赋值
    findEnables: function() {
        this.findByTypeCode("10001",this.setEnables)
    },
    // 查询状态下拉框数据成功后的回调
    setEnables: function(isSuccess,json) {
        try{
            if (isSuccess) {
                this.enables = [];
                for (var i = 0; i < json.data.length; i++) {
                    this.enables.push(json.data[i]);
                }
            }
            else {
                this.$message.error(json.msg);
            }
        }
        catch(e){
            alert(e);
        }
    },
     // 为下发状态下拉框赋值
    findSendState: function() {
        this.findByTypeCode("10011",this.setSendStates)
    },
    // 查询状态下拉框数据成功后的回调
    setSendStates: function(isSuccess,json) {
        try{
            if (isSuccess) {
                this.sendStateGroup = [];
                for (var i = 0; i < json.data.length; i++) {
                    this.sendStateGroup.push(json.data[i]);
                }
            }
            else {
                this.$message.error(json.msg);
            }
        }
        catch(e){
            alert(e);
        }
    },
    findStates:function(){
      this.findByTypeCode("10015",this.setStates);
    },
    setStates:function(isSuccess,json){
      try{
        if(isSuccess){
          this.States=[];
          for(var i=0 ; i < json.data.length ; i++){
            this.States.push(json.data[i]);
          }
        }else{
          this.$message.error(json.msg);
        }
      }catch(e){
        alert(e);
      }
    },
    initTable:function(){
      this.tableHeight = this.$refs.context.offsetHeight - this.$refs.queryBox.offsetHeight;
      this.isInit = true;
    },
    enterDown(){
      var g = this
      if(g.isShowEditForm){
        g.submitForm('editForm',g.currentResCode)
      }else if(g.isShowEditForm2){
        g.comfirmSend('sendForm',g.currentResCode)
      }else if(g.isShowInfoForm4){
        g.onQuery2()
      }else if(!g.loading){
        g.onQuery()
      }
    }

  },
  mounted: function mounted() {
    this.findChannelNameGroup();
    this.onQuery();
    this.findEnables();
    this.findSendState();
    this.findStates();
    this.findSite();
    window.setTimeout(this.initTable,100);

  },
 components: {
        // "shell-info": subAssetsInfo,
        // "Sub-assetInformation": subAssetInformation,
        "Look-trash": ProgramList,
         'upload-file': () => import('../common/UploadFile')
  }
}


</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
.avatar {
width: 178px;
height: 178px;
display: block;
}
</style>
